package cate.common.table.pvp.crossboss;

import cate.common.table.ESheet;
import cate.common.util.random.RWList;
import easy.java.dev.note.NoteClass;

import java.util.HashMap;
import java.util.Map;

@NoteClass("奖励分组")
public class CrossBossRwdGroupSheet extends ESheet<CrossBossRwdGroupRow> {
    @Override
    public String getSheetName() {
        return "奖励分组";
    }

    private Map<Integer, RWList<CrossBossRwdGroupRow>> rwMap;

    protected void onLoaded() {
        rwMap = new HashMap<>();
        for (CrossBossRwdGroupRow row : this.getList()) {
            RWList<CrossBossRwdGroupRow> rwList = rwMap.get(row.group);
            if (rwList == null) {
                rwList = new RWList<>();
                rwMap.put(row.group, rwList);
            }
            rwList.add(row);
        }
        rwMap.values().forEach(RWList::setup);
    }

    public CrossBossRwdGroupRow random(int group) {
        RWList<CrossBossRwdGroupRow> rwList = rwMap.get(group);
        if (rwList == null) {
            return null;
        }
        return rwList.get();
    }
}
